{% extends "tasks/base.html" %}

{% load i18n %}
{% load account_tags %}
{% load tasks_tags %}
{% load shorttimesince_tag %}
{% load humanize %}
{% load group_tags %}

{% block head_title %}Tasks for {% user_display other_user %}{% endblock %}

{% block body %}
    <h1>Tasks for <a href="{% url profile_detail other_user %}">{% user_display other_user %}</a></h1>
    
    <p>You can drag this '<a href="{{ bookmarklet }}">{{ SITE_NAME }} Tasks</a>' link to your bookmark bar to quickly get to your open tasks!</p>
    
    
    <h2>Nudged Tasks</h2>
    
    {% if nudged_tasks %}
        
        <form action="" method="GET">
            <div class="task_filter">
                <ul>
                    {{ nudged_filter.form.as_ul }}
                    <li><input type="submit" value="filter"/></li>
                </ul>
            </div>
        </form>
        
        
        {% regroup nudged_tasks by get_state_display as grouped_tasks %}
        
        <table class="task_list">
            <tr>
                <th>ID</th>
                <th>Summary</th>
                <th>Last Modified</th>
                <th>Tags</th>
                <th>Status</th>
            </tr>
            {% for section in grouped_tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            <span class="arrow">&#x25BE;</span>
                            {{ section.grouper }}
                            <span class="count">({{ section.list|length }})</span>
                        </span>
                    </td>
                </tr></tbody>
                <tbody class="task_group" id="group_{{ forloop.counter }}">
                    {% for task in section.list %}
                        <tr class="task_{{ task.get_state_display }} {% cycle odd,even %}">
                            <td>{{ task.id }}</td>
                            <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                            <td style="white-space: nowrap">{{ task.modified|shorttimesince }} ago</td>
                            <td>{% task_tags task group %}</td>
                            <td>{{ task.status }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            {% endfor %}
        </table>
        
    {% else %}
        {% trans "You have no nudged tasks right now." %}
    {% endif %}
    
    
    <h2>Assigned Tasks</h2>
    
    {% if assigned_tasks %}
        
        <form action="" method="GET">
            <div class="task_filter">
                <ul>
                    {{ assigned_filter.form.as_ul }}
                    <li><input type="submit" value="filter"/></li>
                </ul>
            </div>
        </form>
        
        {% regroup assigned_tasks by get_state_display as grouped_tasks %}
        
        <table class="task_list">
            <tr>
                <th>ID</th>
                <th>Summary</th>
                <th>Last Modified</th>
                <th>Tags</th>
                <th>Status</th>
            </tr>
            {% for section in grouped_tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            <span class="arrow">&#x25BE;</span>
                            {{ section.grouper }}
                            <span class="count">({{ section.list|length }})</span>
                        </span>
                    </td>
                </tr></tbody>
                <tbody class="task_group" id="group_{{ forloop.counter }}">
                    {% for task in section.list %}
                        <tr class="task_{{ task.get_state_display }} {% cycle odd,even %}">
                            <td>{{ task.id }}</td>
                            <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                            <td style="white-space: nowrap">{{ task.modified|shorttimesince }} ago</td>
                            <td>{% task_tags task group %}</td>
                            <td>{{ task.status }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            {% endfor %}
        </table>
        
    {% else %}
        {% trans "You have no assigned tasks right now." %}
    {% endif %}
    
    
    <h2>Created Tasks</h2>
    
    {% if created_tasks %}
        
        <form action="" method="GET">
            <div class="task_filter">
                <ul>
                    {{ created_filter.form.as_ul }}
                    <li><input type="submit" value="filter"/></li>
                </ul>
            </div>
        </form>
        
        {% regroup created_tasks by get_state_display as grouped_tasks %}
        
        <table class="task_list">
            <tr>
                <th>ID</th>
                <th>Summary</th>
                <th>Last Modified</th>
                <th>Tags</th>
                <th>Status</th>
            </tr>
            {% for section in grouped_tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            <span class="arrow">&#x25BE;</span>
                            {{ section.grouper }}
                            <span class="count">({{ section.list|length }})</span>
                        </span>
                    </td>
                </tr></tbody>
                <tbody class="task_group" id="group_{{ forloop.counter }}">
                    {% for task in section.list %}
                        <tr class="task_{{ task.get_state_display }} {% cycle odd,even %}">
                            <td>{{ task.id }}</td>
                            <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                            <td style="white-space: nowrap">{{ task.modified|shorttimesince }} ago</td>
                            <td>{% task_tags task group %}</td>
                            <td>{{ task.status }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            {% endfor %}
        </table>
        
    {% else %}
        {% trans "You have no created tasks right now." %}
    {% endif %}
    
{% endblock %}
